using System;
using System.Collections.Generic;

namespace OffsetPath
{
    public class ForseArco2ClassQ : ClasseBaseLineaArcoClassAf
    {
        protected ForseLineaClassA a;
        public bool b;
        public bool c;
        public double d;

        public ForseArco2ClassQ()
        {
            this.a = new ForseLineaClassA();
        }

        public ForseArco2ClassQ(ForseArco2ClassQ A_0)
        {
            this.a = new ForseLineaClassA();
            this.MethodA(A_0);
        }

        public ForseArco2ClassQ(ForseLineaClassA classA0, double A_1, bool A_2, bool A_3)
        {
            this.a = new ForseLineaClassA();
            this.GetLinea().c(classA0);
            this.d = A_1;
            this.c = A_2;
            this.b = A_3;
        }

        public ForseArco2ClassQ(PuntoDueD A_0, ClassAtPuntoIncrementale A_1, double A_2, bool A_3, bool A_4)
        {
            this.a = new ForseLineaClassA();
            this.GetLinea().MethodA(A_0, A_1);
            this.d = A_2;
            this.c = A_3;
            this.b = A_4;
        }

        public ForseArco2ClassQ(PuntoDueD A_0, PuntoDueD A_1, double A_2, bool A_3, bool A_4)
        {
            this.a = new ForseLineaClassA();
            this.GetLinea().MethodA(A_0, A_1);
            this.d = A_2;
            this.c = A_3;
            this.b = A_4;
        }

        public override ClasseBaseLineaArcoClassAf MethodA()
        {
            return new ForseArco2ClassQ(this);
        }

        public void MethodA(ForseArco2ClassQ A_0)
        {
            this.GetLinea().c(A_0.GetLinea());
            this.d = A_0.d;
            this.c = A_0.c;
            this.b = A_0.b;
        }

        public PuntoDueD MethodA(double A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.e());
            ForseLineaClassA classA = new ForseLineaClassA(puntoDueD, this.GetLinea().a);
            ForseLineaClassA a2 = new ForseLineaClassA(puntoDueD, this.GetLinea().i());
            if (!this.b)
            {
                double num = classA.b.c(a2.b) * A_0;
                classA.b.MethodB(num);
                return classA.i();
            }
            double num2 = classA.b.d(a2.b) * A_0;
            classA.b.c(num2);
            return classA.i();
        }

        public bool MethodA(ForseLineaClassA classA0, List<PuntoDueD> A_1)
        {
            double num = classA0.a.MethodC(this.e());
            ForseLineaClassA classA = new ForseLineaClassA(classA0);
            classA.b.MethodA((double) ((num + this.d) * 2.0));
            return this.MethodB(classA, A_1);
        }

        public void MethodA(ForseLineaClassA classA0, PuntoDueD A_1)
        {
            this.GetLinea().c(classA0);
            PuntoDueD puntoDueD = new PuntoDueD(this.GetLinea().i());
            ClassG classG = new ClassG();
            classG.MethodB(this.GetLinea().a, puntoDueD, A_1);
            this.d = this.GetLinea().a.MethodC(classG.d());
            this.b = this.GetLinea().MethodB(A_1);
            this.c = this.GetLinea().MethodB(classG.d());
        }

        public bool MethodA(ForseArco2ClassQ A_0, List<PuntoDueD> A_1)
        {
            ClassG classG = new ClassG(this.e(), this.d);
            ClassG g2 = new ClassG(A_0.e(), A_0.d);
            List<PuntoDueD> list = new List<PuntoDueD>();
            if (!classG.MethodA(g2, list))
            {
                return false;
            }
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if ((((this.GetLinea().MethodB(list[i]) ^ this.b) || (A_0.GetLinea().MethodB(list[i]) ^ A_0.b)) || (list[i].MethodB(this.GetLinea().a) || list[i].MethodB(this.GetLinea().i()))) || (list[i].MethodB(A_0.h()) || list[i].MethodB(A_0.i())))
                {
                    list.RemoveAt(i);
                }
            }
            if (list.Count == 0)
            {
                return false;
            }
            A_1.InsertRange(0, list);
            return true;
        }

        public double MethodA(ForseLineaClassA classA0, PuntoDueD A_1, PuntoDueD A_2)
        {
            double num = new ClassG(this.e(), this.d).MethodA(classA0, A_1, A_2);
            double num2 = 0.0;
            if (!(classA0.MethodB(A_1) ^ this.b))
            {
                return Math.Abs(num);
            }
            A_1.e(this.GetLinea().a);
            num2 = classA0.MethodD(A_1, A_2);
            PuntoDueD puntoDueD = new PuntoDueD(this.GetLinea().i());
            PuntoDueD x2 = new PuntoDueD();
            double num3 = classA0.MethodD(puntoDueD, x2);
            if (num3 < num2)
            {
                num2 = num3;
                A_1.e(puntoDueD);
                A_2.e(x2);
            }
            if (num < 0.0)
            {
                double num4 = this.MethodD(classA0.a, puntoDueD);
                if (num4 < num2)
                {
                    num2 = num4;
                    A_1.e(puntoDueD);
                    A_2.e(this.GetLinea().a);
                }
                double num5 = this.MethodD(classA0.i(), puntoDueD);
                if (num5 < num2)
                {
                    num2 = num5;
                    A_1.e(puntoDueD);
                    A_2.e(this.GetLinea().i());
                }
            }
            return num2;
        }

        public double MethodA(ForseArco2ClassQ A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            List<PuntoDueD> list = new List<PuntoDueD>();
            List<PuntoDueD> list2 = new List<PuntoDueD>();
            PuntoDueD puntoDueD = new PuntoDueD(this.e());
            PuntoDueD x2 = new PuntoDueD(A_0.e());
            ClassG classG = new ClassG(puntoDueD, this.d);
            ClassG g2 = new ClassG(x2, A_0.d);
            if (classG.MethodA(g2, list))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if ((this.GetLinea().MethodB(list[i]) == this.b) && (A_0.GetLinea().MethodB(list[i]) == A_0.b))
                    {
                        A_1.e(list[i]);
                        A_2.e(list[i]);
                        return 0.0;
                    }
                }
                list.Clear();
            }
            ForseLineaClassA classA = new ForseLineaClassA {
                            a = new PuntoDueD(puntoDueD),
                            b = new ClassAtPuntoIncrementale(puntoDueD, x2)
                        };
            classA.MethodB((double) (Math.Max(this.d, A_0.d) * 10.0));
            double num2 = 1.7E+308;
            double num3 = 0.0;
            if (this.MethodB(classA, list) && A_0.MethodB(classA, list2))
            {
                for (int j = 0; j < list.Count; j++)
                {
                    for (int k = 0; k < list2.Count; k++)
                    {
                        num3 = list[j].MethodC(list2[k]);
                        if (num3 < num2)
                        {
                            A_1.e(list[j]);
                            A_2.e(list2[k]);
                            num2 = num3;
                        }
                    }
                }
            }
            PuntoDueD x3 = new PuntoDueD();
            num3 = this.MethodD(A_0.h(), x3);
            if (num3 < num2)
            {
                A_1.e(x3);
                A_2.e(A_0.h());
                num2 = num3;
            }
            num3 = this.MethodD(A_0.i(), x3);
            if (num3 < num2)
            {
                A_1.e(x3);
                A_2.e(A_0.i());
                num2 = num3;
            }
            PuntoDueD x4 = new PuntoDueD();
            num3 = A_0.MethodD(this.h(), x4);
            if (num3 < num2)
            {
                A_1.e(this.h());
                A_2.e(x4);
                num2 = num3;
            }
            num3 = A_0.MethodD(this.i(), x4);
            if (num3 < num2)
            {
                A_1.e(this.i());
                A_2.e(x4);
                num2 = num3;
            }
            return num2;
        }

        public void MethodA(ForseLineaClassA classA0, double A_1, bool A_2, bool A_3)
        {
            this.GetLinea().c(classA0);
            this.d = A_1;
            this.c = A_2;
            this.b = A_3;
        }

        public void MethodA(PuntoDueD A_0, ClassAtPuntoIncrementale A_1, double A_2, bool A_3, bool A_4)
        {
            this.GetLinea().MethodA(A_0, A_1);
            this.d = A_2;
            this.c = A_3;
            this.b = A_4;
        }

        public void MethodA(PuntoDueD A_0, PuntoDueD A_1, double A_2, bool A_3, bool A_4)
        {
            this.GetLinea().MethodA(A_0, A_1);
            this.d = A_2;
            this.c = A_3;
            this.b = A_4;
        }

        public PuntoDueD MethodB()
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.e());
            PuntoDueD x2 = new PuntoDueD(this.GetLinea().p());
            ForseLineaClassA classA = new ForseLineaClassA(puntoDueD, x2);
            if ((classA.b.a == 0.0) && (classA.b.b == 0.0))
            {
                classA.c(this.GetLinea());
                classA.MethodA(x2);
                if (this.b)
                {
                    classA.b.MethodB();
                }
                else
                {
                    classA.b.e();
                }
            }
            else
            {
                classA.MethodA(this.d);
                if (this.b == this.c)
                {
                    classA.b.d();
                }
            }
            return classA.i();
        }

        public bool MethodB(ForseLineaClassA classA0, List<PuntoDueD> A_1)
        {
            List<PuntoDueD> list = new List<PuntoDueD>();
            ClassG classG = new ClassG(this.e(), this.d);
            if (!classG.MethodB(classA0, list))
            {
                return false;
            }
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (((this.GetLinea().MethodB(list[i]) ^ this.b) || list[i].MethodB(this.GetLinea().a)) || list[i].MethodB(this.GetLinea().i()))
                {
                    list.RemoveAt(i);
                }
            }
            if (list.Count == 0)
            {
                return false;
            }
            A_1.InsertRange(0, list);
            return true;
        }

        public override bool MethodB(ClasseBaseLineaArcoClassAf A_0, List<PuntoDueD> A_1)
        {
            if (A_0 is ForseLineaClassA)
            {
                return this.MethodB(A_0 as ForseLineaClassA, A_1);
            }
            return ((A_0 is ForseArco2ClassQ) && this.MethodA(A_0 as ForseArco2ClassQ, A_1));
        }

        public double MethodC()
        {
            if (!this.MethodD())
            {
                return 0.0;
            }
            return (2.0 * Math.Asin((this.GetLinea().b.c() / 2.0) / this.d));
        }

        public override double MethodC(PuntoDueD A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            return this.MethodD(A_0, puntoDueD);
        }

        public bool MethodD()
        {
            return (this.GetLinea().b.c() <= (2.0 * this.d));
        }

        public override double MethodD(PuntoDueD A_0, PuntoDueD A_1)
        {
            PuntoDueD puntoDueD = new PuntoDueD(this.e());
            ClassG classG = new ClassG(puntoDueD, this.d);
            PuntoDueD x2 = new PuntoDueD();
            double num = classG.MethodB(A_0, x2);
            if (this.b ^ this.GetLinea().MethodB(x2))
            {
                double num2 = A_0.MethodC(this.GetLinea().a);
                double num3 = A_0.MethodC(this.GetLinea().i());
                if (num2 < num3)
                {
                    A_1.e(this.GetLinea().a);
                    return num2;
                }
                A_1.e(this.GetLinea().i());
                return num3;
            }
            A_1.e(x2);
            return Math.Abs(num);
        }

        public PuntoDueD e()
        {
            if (!this.MethodD())
            {
                return new PuntoDueD(0.0, 0.0);
            }
            PuntoDueD puntoDueD = new PuntoDueD(this.GetLinea().p());
            double num = puntoDueD.MethodC(this.GetLinea().a);
            double num2 = Math.Sqrt((this.d * this.d) - (num * num));
            ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(this.GetLinea().b);
            if (this.c)
            {
                classAt.MethodB();
            }
            else
            {
                classAt.e();
            }
            classAt.MethodA(num2);
            return puntoDueD.MethodB(classAt);
        }

        public override double e(ClasseBaseLineaArcoClassAf A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            if (A_0 is ForseLineaClassA)
            {
                return this.MethodA(A_0 as ForseLineaClassA, A_1, A_2);
            }
            if (A_0 is ForseArco2ClassQ)
            {
                return this.MethodA(A_0 as ForseArco2ClassQ, A_1, A_2);
            }
            return 0.0;
        }

        public ForseLineaClassA GetLinea()
        {
            return this.a;
        }

        public override void f(ClassAb A_0)
        {
            if (this.MethodD())
            {
                PuntoDueD puntoDueD = new PuntoDueD(this.e());
                PuntoDueD x2 = new PuntoDueD(this.GetLinea().i());
                this.GetLinea().f(A_0);
                if (((this.GetLinea().a.X - puntoDueD.X) * (x2.X - puntoDueD.X)) < 0.0)
                {
                    if (this.GetLinea().p().Y > puntoDueD.Y)
                    {
                        if (this.c ^ this.b)
                        {
                            A_0.d((double) (puntoDueD.Y + this.d));
                        }
                        else
                        {
                            A_0.g((double) (puntoDueD.Y - this.d));
                        }
                    }
                    else if (this.c ^ this.b)
                    {
                        A_0.g((double) (puntoDueD.Y - this.d));
                    }
                    else
                    {
                        A_0.d((double) (puntoDueD.Y + this.d));
                    }
                }
                else if (!(this.c ^ this.b))
                {
                    A_0.g((double) (puntoDueD.Y - this.d));
                    A_0.d((double) (puntoDueD.Y + this.d));
                }
                if (((this.GetLinea().a.Y - puntoDueD.Y) * (x2.Y - puntoDueD.Y)) < 0.0)
                {
                    if (this.GetLinea().p().X > puntoDueD.X)
                    {
                        if (this.c ^ this.b)
                        {
                            A_0.MethodA((double) (puntoDueD.X + this.d));
                        }
                        else
                        {
                            A_0.c((double) (puntoDueD.X - this.d));
                        }
                    }
                    else if (this.c ^ this.b)
                    {
                        A_0.c((double) (puntoDueD.X - this.d));
                    }
                    else
                    {
                        A_0.MethodA((double) (puntoDueD.X + this.d));
                    }
                }
                else if (!(this.c ^ this.b))
                {
                    A_0.c((double) (puntoDueD.X - this.d));
                    A_0.MethodA((double) (puntoDueD.X + this.d));
                }
            }
        }

        ~ForseArco2ClassQ()
        {
        }

        public override double g()
        {
            if (this.c ^ this.b)
            {
                return (this.d * this.MethodC());
            }
            return (this.d * (ClassK.ad - this.MethodC()));
        }

        public override PuntoDueD h()
        {
            return new PuntoDueD(this.GetLinea().a);
        }

        public override PuntoDueD i()
        {
            return new PuntoDueD(this.GetLinea().i());
        }

        public override void j(List<PuntoDueD> A_0, List<ClasseBaseLineaArcoClassAf> A_1)
        {
            int count = A_0.Count;
            if (count == 0)
            {
                A_1.Add(new ForseArco2ClassQ(this));
            }
            else
            {
                ClassAq classAq = new ClassAq();
                classAq.a(A_0);
                if (count > 1)
                {
                    ForseLineaClassA classA = new ForseLineaClassA(this.GetLinea().p(), this.GetLinea().a);
                    if (this.b)
                    {
                        classAq.b(classA);
                    }
                    else
                    {
                        classAq.a(classA);
                    }
                }
                PuntoDueD puntoDueD = new PuntoDueD(this.e());
                ForseLineaClassA a2 = new ForseLineaClassA(this.GetLinea().a, classAq[0]);
                A_1.Add(new ForseArco2ClassQ(a2, this.d, a2.MethodB(puntoDueD), this.b));
                for (int i = 1; i < count; i++)
                {
                    a2.MethodA(classAq[i - 1], classAq[i]);
                    A_1.Add(new ForseArco2ClassQ(a2, this.d, a2.MethodB(puntoDueD), this.b));
                }
                a2.MethodA(classAq[classAq.Count - 1], this.GetLinea().i());
                A_1.Add(new ForseArco2ClassQ(a2, this.d, a2.MethodB(puntoDueD), this.b));
            }
        }

        public override void k(ForseLineaClassA classA0, ClassAj A_1)
        {
            ForseArco2ClassQ classQ = new ForseArco2ClassQ(this);
            ForseLineaClassA classA = new ForseLineaClassA(classA0);
            double num = classA.b.f();
            classA.b.c(num);
            classQ.GetStartPoint(-num, classA.a);
            ClassAb classAb = new ClassAb();
            classQ.f(classAb);
            A_1.a = classAb.f() - classA.a.Y;
            A_1.b = A_1.a;
            A_1.MethodB((double) (classAb.k() - classA.a.Y));
        }

        public override void l(ClassAtPuntoIncrementale A_0, ClassAj A_1)
        {
            ForseArco2ClassQ classQ = new ForseArco2ClassQ(this);
            ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(A_0);
            double num = classAt.f();
            classAt.c(num);
            classQ.GetStartPoint(-num, new PuntoDueD(0.0, 0.0));
            ClassAb classAb = new ClassAb();
            classQ.f(classAb);
            A_1.a = classAb.f() - classAt.b;
            A_1.b = A_1.a;
            A_1.MethodB((double) (classAb.k() - classAt.b));
        }

        public override void m()
        {
            this.GetLinea().m();
            this.b = !this.b;
            this.c = !this.c;
        }

        public override void n(ClassAg A_0)
        {
            this.GetLinea().n(A_0);
            double num = this.GetLinea().b.c();
            if (num > (2.0 * this.d))
            {
                this.d = num / 1.999999999999;
            }
        }

        public override void o(double A_0, PuntoDueD A_1)
        {
            this.GetLinea().o(A_0, A_1);
            this.d *= A_0;
        }

        public override void p(ClassAtPuntoIncrementale A_0)
        {
            this.GetLinea().p(A_0);
        }

        public override void q(ForseLineaClassA classA0)
        {
            this.GetLinea().q(classA0);
            this.b = !this.b;
            this.c = !this.c;
        }

        public override void r(PuntoDueD A_0)
        {
            this.GetLinea().r(A_0);
        }

        public override void GetStartPoint(double A_0, PuntoDueD A_1)
        {
            this.GetLinea().GetStartPoint(A_0, A_1);
        }
    }
}

